/*
 * 个人风采 
 */
import 'package:flutter/material.dart';
import 'package:grouped_list/grouped_list.dart';
import './webView.dart'; // web-view

List _elements = [
  {'name': '百度', 'group': '混合', 'http': 'https://www.baidu.com/'},
  {'name': '趴一爬', 'group': '混合', 'http': 'https://www.tuvdance.com/'},
  {'name': '视频生活', 'group': '混合', 'http': 'https://www.tuvdance.com/videoLife'},
  {'name': 'gif', 'group': '混合', 'http': 'https://www.tuvdance.com/gif/'}
];

class PersonWonderful extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('彩蛋'),
        backgroundColor: Colors.green,
      ),
      body: GroupedListView<dynamic, String>(
        groupBy: (element) => element['group'],
        elements: _elements,
        order: GroupedListOrder.DESC,
        useStickyGroupSeparators: true,
        groupSeparatorBuilder: (String value) => Padding(
          padding: const EdgeInsets.all(8.0),
          child: Text(
            value,
            textAlign: TextAlign.center,
            style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
          ),
        ),
        itemBuilder: (c, element) {
          return Card(
            elevation: 8.0,
            margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
            child: Container(
              child: ListTile(
                contentPadding:
                    EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
                leading: Icon(Icons.info),
                title: Text(element['name']),
                trailing: Icon(Icons.arrow_forward),
                onTap: () {
                  Navigator.push(context, MaterialPageRoute(builder: (context) {
                    return WebViewState(value: element);
                  }));
                },
              ),
            ),
          );
        },
      ),
    );
  }
}
